#!/usr/bin/env python

import sys
import MySQLdb

# print len(sys.argv),' args'

# if len(sys.argv) > 1:
#     filename = sys.argv[1]
# else:
#     print 'Usage: ',sys.argv[0],' filename'
#     sys.exit(1)

tname = 'IRDB_TEST'
# Open database connection
DB = MySQLdb.connect('localhost','gerald','My?DB!','BankOfEngland' )
cursor = DB.cursor()

# check
count=int(0)
sql = 'SELECT DATE FROM ' + tname
cursor.execute(sql)
for row in cursor.fetchall():
    print row[0]
    count += 1

DB.close()

print count,' records'
sys.exit(0)

# get a list of tables
# cursor.execute('SHOW TABLES')
# tables = cursor.fetchall()
# creates a tuple
# for table in tables:
#     print "Tables: %s " % table
#     sql = 'DESCRIBE ' + table[0]
#     print 'SQL = ',sql
#     cursor.execute(sql)
#     results = cursor.fetchall()
#     for row in results:
#         print row
#result = cursor.fetchall()
#print result
